package com;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

public class StreamDownloadController {

    @RequestMapping(value = "/demo")
    @ResponseBody
    public void index(@RequestBody byte[] bytes) throws IOException {
        Map<String, String> map = new HashMap<>();
        //        byte[] bytes = IOUtils.toByteArray(file.getInputStream());
        System.out.println(bytes.length);
        OutputStream stream = FileUtils.openOutputStream(new File("test_copy"));
        IOUtils.write(bytes, stream);
        stream.flush();
        stream.close();
    }



}